<!-- ParallaxSection.vue -->
<template>
  <div class="parallaxSection" :style="{ backgroundImage: `url(${imageUrl})` }">
    <div class="contentContainer">
      <h2 class="title">{{ title }}</h2>
      <p class="description">{{ description }}</p>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  imageUrl: { type: String, required: true },
  title: { type: String, default: '' },
  description: { type: String, default: '' },
  needBottom: { type: Boolean, default: false }
})
</script>

<style scoped lang="scss">
.parallaxSection {
  width: 100%;
  height: 100vh;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  /* 关键样式：背景固定在视口 */
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;

  .contentContainer {
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    padding: 2px;
    background: rgba(0, 0, 0, 0.5);
    /* 半透明遮罩增强可读性 */

    .title {
      font-size: 2.5px;
      margin-bottom: 1px;
    }

    .description {
      font-size: 1.2px;
      max-width: 600px;
    }

    .bottomMask {
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 20px;
      background: linear-gradient(to top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0));
    }
  }
}
</style>